<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>酒店后台管理系统</title>
<jsp:include page="../commonCss.jsp" />
</head>
<body>
	<div class="layui-fluid">
		<div id="select">
			<div class="select_top">
				<div class="select_top_title">
					<span class="layui-breadcrumb" style="visibility:visible;padding: 12px 0 12px 20px;">
	                  <a href="" style="font-size:18px;">房间管理</a>
	                  <span lay-separator style="font-size:18px;">/</span>
	                  <a href="" style="font-size:18px;">查询房间</a>
	                  <span lay-separator style="font-size:18px;">/</span>
	                  <a href="" style="font-size:18px;"><cite>修改房间</cite></a>
	              	</span>
	              	<img style="float:right;margin-right:20px;" src="${pageContext.request.contextPath}/resources/img/icon_refresh.png" title="刷新当前页面"
              		width="25" height="25"/>
				</div>
			</div>
			<div class="select_nav1">
				<span>修改房间</span>
				<hr>
				<div style="height:430px;">
					<form action="" method="post">
						<label>房间编号</label>
						<input type="text" name="roomBh" id="roomBh" class="layui-disabled" disabled required="required"></input><br/>
						<label>所属酒店</label>
						<input type="text" name="roomName" id="roomName" class="layui-disabled" disabled required="required"></input><br/>
						<label>房间类别</label>
						<select name="roomType" id="roomType" required="required">
							<option value="0">标准间</option>
							<option value="1">双人间</option>
							<option value="2">三人间</option>
						</select><br/>
						<label>房间价格</label>
						<input type="text" name="roomPrice" id="roomPrice" placeholder="请输入价格" required="required"></input><br/>
						<label>房间楼层</label>
						<input type="text" name="roomFloor" id="roomFloor" class="layui-disabled" disabled required="required"></input><br/>
						<label>&nbsp;&nbsp;&nbsp;房间号</label>
						<input type="text" name="roomNumber" id="roomNumber" class="layui-disabled" disabled placeholder="请输入房间号,例如0101" required="required"></input><br/>
						<label>修改时间</label>
						<input type="text" name="roomUpdateTime" id="roomUpdateTime" class="layui-disabled" disabled required="required"></input><br/>
						<input type="button" style="letter-spacing: 0px;" value="修改" class="btn"></input>
					</form>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="https://layui.11dz.cn/layui-v2.6.8/layui/layui.js"></script>
<script src="${pageContext.request.contextPath}/resources/js/jquery-3.6.0.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/js/jquery-cookie.js"></script>
<script type="text/javascript">
	layui.use('layer', function(){
	  var layer = layui.layer;
	  if(<%=request.getSession().getAttribute("username")%> !=null){
		  layer.msg("欢迎来到酒店后台管理系统");
     }else{
   	  alert("请登录");
   	  window.open("${pageContext.request.contextPath}/views/admin/user/login.jsp");
     }
	});
	function datetime() {
		 var now = new Date();
		 var s = now.getSeconds();
		 if(s <= 9){
			 s = "0" + now.getSeconds();
		 }
		 if(now.getMinutes() <= 9){
			 document.getElementById("roomUpdateTime").value = now.getFullYear() + "-"
			 + (now.getMonth() + 1) + "-" + now.getDate();
			 document.getElementById("roomUpdateTime").value += " " + now.getHours() + ":"
			 + "0" + now.getMinutes() + ":" + s;
		 }else{
			 document.getElementById("roomUpdateTime").value = now.getFullYear() + "-"
			 + (now.getMonth() + 1) + "-" + now.getDate();
			 document.getElementById("roomUpdateTime").value += " " + now.getHours() + ":"
			 + now.getMinutes() + ":" + s;
		 }
	}
	window.setInterval("datetime()", 1000);
	window.onload = function(){
		var roomBh = "<%=request.getParameter("roomBh")%>";
		var roomName = "<%=request.getParameter("roomName")%>";
		var roomFloor = "<%=request.getParameter("roomFloor")%>";
		var roomNumber = "<%=request.getParameter("roomNumber")%>";
		document.getElementById("roomBh").value = roomBh;
		document.getElementById("roomName").value = roomName;
		document.getElementById("roomFloor").value = roomFloor;
		document.getElementById("roomNumber").value = roomNumber;
	}
	$(document).ready(function(){
		$('.btn').on('click', function() {
			layui.use('layer', function(){
			  var layer = layui.layer;
			  layer.confirm('是否确定修改', function(){
				  $.ajax({
					url : "${pageContext.request.contextPath}/room/update",
					data : {
						'roomBh' : $('#roomBh').val(),
						'roomType' : $('#roomType').val(),
						'roomPrice' : $('#roomPrice').val(),
						'roomUpdateTime' : $('#roomUpdateTime').val()
					},
					type : "post",
					dataType : "json",
					success : function(data) {
						localStorage.setItem("isroomupdate", JSON.stringify(data));//这里是设置
						window.parent.layer.closeAll();
					},
					error : function(data) {
						layer.msg("修改失败");
						location.reload();
					}
				});
		      });
			});
		});
	});
	$(document).ready(function(){
		$('img').on('click', function() {
			location.reload();
		});
	});
</script>
</html>